<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Exchange rates</title>
</head>
<body>
<form action="index.php" method="post" name="exchange_form" id="exchange_form">
	<fieldset>
		<label for="currency">Select a currency: </label>
		<select id="currency" name="currency" style="">

	         <option value="EUR" SELECTED>EUR - Euro</option>
             <option value="USD">USD - United States Dollars</option>
             <option value="GBP">GBP - United Kingdom Pounds</option>
             <option value="CAD">CAD - Canada Dollars</option>
             <option value="AUD">AUD - Australia Dollars</option>

             <option value="JPY">JPY - Japan Yen</option>
             <option value="INR">INR - India Rupees</option>
             <option value="NZD">NZD - New Zealand Dollars</option>
             <option value="CHF">CHF - Switzerland Francs</option>
             <option value="ZAR">ZAR - South Africa Rand</option>
             <option value="AFN">AFN - Afghanistan Afghanis</option>
             <option value="ALL">ALL - Albania Leke</option>
             <option value="DZD">DZD - Algeria Dinars</option>
             <option value="USD">USD - America (United States) Dollars</option>
             <option value="ARS">ARS - Argentina Pesos</option>
             <option value="AUD">AUD - Australia Dollars</option>

             <option value="ATS">ATS - Austria Schillings</OPTION>
             <option value="BSD">BSD - Bahamas Dollars</option>
             <option value="BHD">BHD - Bahrain Dinars</option>
             <option value="BDT">BDT - Bangladesh Taka</option>
             <option value="BBD">BBD - Barbados Dollars</option>
             <option value="BEF">BEF - Belgium Francs</OPTION>

             <option value="BMD">BMD - Bermuda Dollars</option>
             <option value="BRL">BRL - Brazil Reais</option>
             <option value="BGN">BGN - Bulgaria Leva</option>
             <option value="CAD">CAD - Canada Dollars</option>
             <option value="XOF">XOF - CFA BCEAO Francs</option>
             <option value="XAF">XAF - CFA BEAC Francs</option>

             <option value="CLP">CLP - Chile Pesos</option>
             <option value="CNY">CNY - China Yuan Renminbi</option>
             <option value="CNY">CNY - RMB (China Yuan Renminbi)</option>
             <option value="COP">COP - Colombia Pesos</option>
             <option value="XPF">XPF - CFP Francs</option>
             <option value="CRC">CRC - Costa Rica Colones</option>

             <option value="HRK">HRK - Croatia Kuna</option>
             <option value="CYP">CYP - Cyprus Pounds</option>
             <option value="CZK">CZK - Czech Republic Koruny</option>
             <option value="DKK">DKK - Denmark Kroner</option>
             <option value="DEM">DEM - Deutsche (Germany) Marks</OPTION>
             <option value="DOP">DOP - Dominican Republic Pesos</option>

             <option value="NLG">NLG - Dutch (Netherlands) Guilders</OPTION>
             <option value="XCD">XCD - Eastern Caribbean Dollars</option>
             <option value="EGP">EGP - Egypt Pounds</option>
             <option value="EEK">EEK - Estonia Krooni</option>
             <option value="EUR">EUR - Euro</option>
             <option value="FJD">FJD - Fiji Dollars</option>

             <option value="FIM">FIM - Finland Markkaa</OPTION>
             <option value="FRF">FRF - France Francs</OPTION>
             <option value="DEM">DEM - Germany Deutsche Marks</OPTION>
             <option value="XAU">XAU - Gold Ounces</option>
             <option value="GRD">GRD - Greece Drachmae</OPTION>
             <option value="NLG">NLG - Holland (Netherlands) Guilders</OPTION>

             <option value="HKD">HKD - Hong Kong Dollars</option>
             <option value="HUF">HUF - Hungary Forint</option>
             <option value="ISK">ISK - Iceland Kronur</option>
             <option value="XDR">XDR - IMF Special Drawing Right</option>
             <option value="INR">INR - India Rupees</option>
             <option value="IDR">IDR - Indonesia Rupiahs</option>

             <option value="IRR">IRR - Iran Rials</option>
             <option value="IQD">IQD - Iraq Dinars</option>
             <option value="IEP">IEP - Ireland Pounds</OPTION>
             <option value="ILS">ILS - Israel New Shekels</option>
             <option value="ITL">ITL - Italy Lire</OPTION>
             <option value="JMD">JMD - Jamaica Dollars</option>

             <option value="JPY">JPY - Japan Yen</option>
             <option value="JOD">JOD - Jordan Dinars</option>
             <option value="KES">KES - Kenya Shillings</option>
             <option value="KRW">KRW - Korea (South) Won</option>
             <option value="KWD">KWD - Kuwait Dinars</option>
             <option value="LBP">LBP - Lebanon Pounds</option>

             <option value="LUF">LUF - Luxembourg Francs</OPTION>
             <option value="MYR">MYR - Malaysia Ringgits</option>
             <option value="MTL">MTL - Malta Liri</option>
             <option value="MUR">MUR - Mauritius Rupees</option>
             <option value="MXN">MXN - Mexico Pesos</option>
             <option value="MAD">MAD - Morocco Dirhams</option>

             <option value="NLG">NLG - Netherlands Guilders</OPTION>
             <option value="NZD">NZD - New Zealand Dollars</option>
             <option value="NOK">NOK - Norway Kroner</option>
             <option value="OMR">OMR - Oman Rials</option>
             <option value="PKR">PKR - Pakistan Rupees</option>
             <option value="XPD">XPD - Palladium Ounces</option>

             <option value="PEN">PEN - Peru Nuevos Soles</option>
             <option value="PHP">PHP - Philippines Pesos</option>
             <option value="XPT">XPT - Platinum Ounces</option>
             <option value="PLN">PLN - Poland Zlotych</option>
             <option value="PTE">PTE - Portugal Escudos</OPTION>
             <option value="QAR">QAR - Qatar Riyals</option>

             <option value="RON">RON - Romania New Lei</option>
             <option value="ROL">ROL - Romania Lei</option>
             <option value="RUB">RUB - Russia Rubles</option>
             <option value="SAR">SAR - Saudi Arabia Riyals</option>
             <option value="XAG">XAG - Silver Ounces</option>
             <option value="SGD">SGD - Singapore Dollars</option>

             <option value="SKK">SKK - Slovakia Koruny</option>
             <option value="SIT">SIT - Slovenia Tolars</option>
             <option value="ZAR">ZAR - South Africa Rand</option>
             <option value="KRW">KRW - South Korea Won</option>
             <option value="ESP">ESP - Spain Pesetas</OPTION>
	         <option value="XDR">XDR - Special Drawing Rights (IMF)</option>
             <option value="LKR">LKR - Sri Lanka Rupees</option>
             <option value="SDG">SDG - Sudan Pounds</option>
             <option value="SEK">SEK - Sweden Kronor</option>
             <option value="CHF">CHF - Switzerland Francs</option>
             <option value="TWD">TWD - Taiwan New Dollars</option>
             <option value="THB">THB - Thailand Baht</option>
             <option value="TTD">TTD - Trinidad and Tobago Dollars</option>
             <option value="TND">TND - Tunisia Dinars</option>
             <option value="TRY">TRY - Turkey Lira</option>
             <option value="AED">AED - United Arab Emirates Dirhams</option>
             <option value="GBP">GBP - United Kingdom Pounds</option>
             <option value="USD">USD - United States Dollars</option>
             <option value="VEB">VEB - Venezuela Bolivares</option>
             <option value="VEF">VEF - Venezuela Bolivares Fuertes</option>
             <option value="VND">VND - Vietnam Dong</option>
             <option value="ZMK">ZMK - Zambia Kwacha</option>
             <!--<option value="EUR">-- Special Units: --</OPTION>
             <option value="XAF">XAF - CFA BEAC Francs</option>
             <option value="XOF">XOF - CFA BCEAO Francs</option>
             <option value="XPF">XPF - CFP Francs</option>
             <option value="XCD">XCD - Eastern Caribbean Dollars</option>
             <option value="EUR">EUR - Euro</option>
             <option value="XDR">XDR - IMF Special Drawing Rights</option>
             <option value="XAU">-- Precious Metals: --</OPTION>
             <option value="XAG">XAG - Silver Ounces</option>
             <option value="XAU">XAU - Gold Ounces</option>
             <option value="XPT">XPT - Platinum Ounces</option>
             <option value="XPD">XPD - Palladium Ounces</option>
		--></select>
		<select name="transform_type" id="transform_type">
			<option value="html">HTML</option>
			<option value="xml">XML</option>
		</select>
		<input type="submit" value="Show exchange rate" />

	</fieldset>
</form>
<?php
if(isset($_POST['currency'])){
	$rssfeed ='http://feeds.currencysource.com/' . $_POST['currency'] . '.xml';
	$xml = new DOMDocument;
	if(!@$xml->load($rssfeed)){
		echo "<div align=\"center\"><b>Not supported this currency code: ". $_POST['currency'] ."</b></div>";
		exit;
	};
	echo "<b><i>Source: $rssfeed</i></b>";
	switch($_POST['transform_type']){
		case 'html':
			{
				//convert to html


				$xsl = new DOMDocument;
				$xsl->load('currency_html.xsl');

				// Configure the transformer
				$proc = new XSLTProcessor;
				$proc->importStyleSheet($xsl); // attach the xsl rules
				echo $proc->transformToXML($xml);
			}
			break;
		case 'xml':
			{
				//convert to xml

				$xsl = new DOMDocument;
				$xsl->load('currency_xml.xsl');

				// Configure the transformer
				$proc = new XSLTProcessor;
				$proc->importStyleSheet($xsl); // attach the xsl rules
				echo "<pre>". htmlspecialchars($proc->transformToXML($xml)) . "</pre>";
			}
			break;
		default:
			break;
	}


}
?>
</body>
</html>
